﻿Public Class SlideInOutControl
    Inherits ContentControl

    Shared Sub New()
        DefaultStyleKeyProperty.OverrideMetadata(GetType(SlideInOutControl), New FrameworkPropertyMetadata(GetType(SlideInOutControl)))
    End Sub



    Public Shared ReadOnly DockProperty As DependencyProperty = _
        DependencyProperty.Register( _
            "Dock", GetType(Dock), GetType(SlideInOutControl), _
            New FrameworkPropertyMetadata( _
                Dock.Left, _
                Sub(d, e) CType(d, SlideInOutControl).OnDockChanged(CType(e.OldValue, Dock), CType(e.NewValue, Dock))))

    Public Property Dock As Dock
        Get
            Return CType(GetValue(DockProperty), Dock)
        End Get
        Set(ByVal value As Dock)
            SetValue(DockProperty, value)
        End Set
    End Property

    Private Sub OnDockChanged(oldValue As Dock, newValue As Dock)

    End Sub



    Public Shared ReadOnly CompletionProperty As DependencyProperty = _
        DependencyProperty.Register( _
            "Completion", GetType(Double), GetType(SlideInOutControl), _
            New FrameworkPropertyMetadata( _
                0.0#, _
                Sub(d, e) CType(d, SlideInOutControl).OnCompletionChanged(CType(e.OldValue, Double), CType(e.NewValue, Double))))

    Public Property Completion As Double
        Get
            Return CType(GetValue(CompletionProperty), Double)
        End Get
        Set(ByVal value As Double)
            SetValue(CompletionProperty, value)
        End Set
    End Property

    Private Sub OnCompletionChanged(oldValue As Double, newValue As Double)

    End Sub



    Public Shared ReadOnly HAmountConverter As IMultiValueConverter =
        ValueConverter.Create3(
            Function(dock As Dock, completion As Double, actualWidth As Double)
                Select Case dock
                    Case Controls.Dock.Left : Return -actualWidth * completion
                    Case Controls.Dock.Right : Return actualWidth * completion
                    Case Else : Return 0.0#
                End Select
            End Function)

    Public Shared ReadOnly VAmountConverter As IMultiValueConverter =
        ValueConverter.Create3(
            Function(dock As Dock, completion As Double, actualHeight As Double)
                Select Case dock
                    Case Controls.Dock.Top : Return -actualHeight * completion
                    Case Controls.Dock.Bottom : Return actualHeight * completion
                    Case Else : Return 0.0#
                End Select
            End Function)

End Class
